package com.lifesting.front;

import javax.el.BeanELResolver;
import javax.el.ELContext;
import javax.el.PropertyNotFoundException;
/**
 * 处理EL表达式中的Wrap对象，让表达式对JSF来说透明化, BUT HOW TO REGISTER THIS RESOLVER???
 * @author cby
 *
 */
public class ExtendBeanElResolver extends BeanELResolver {
	@Override
	public Object getValue(ELContext context, Object base, Object property) {
		Object value = null;
		try{
			value = super.getValue(context, base, property);
		}catch(RuntimeException e){
			if (e instanceof PropertyNotFoundException)
			{
				if (base instanceof IWrap){
					return getValue(context, ((IWrap)base).getWrapped(), property);
				}
			}
			else
			{
				throw e;
			}
		}
		return value;
	}
}
